<template>
<dl :class="$style.container">
  <dt>
    <p>
      <i :class="$style.icon"/>
      <span>{{title}}</span>
    </p>
    <router-link tag="em" :to="{path:'/more'}">更多</router-link>
  </dt>
  <dd v-for="(item,idx) in lists" :key="'comedy'+idx" @click.stop="handleItemClick(item)">
    <div :class="$style.left">
      <img v-lazy="item.poster">
    </div>
    <div :class="$style.right">
      <h4 :class="$style.title">{{item.original_title}}</h4>
      <p :class="$style.count">{{item.wish_count}}人想看</p>
      <div :class="$style.desc">
        <div :class="$style.price">
          <span v-if="item.price" :class="$style.f1"><small>￥</small><strong>{{item.price}}</strong></span>
          <span v-else :class="$style.f2">免费</span>
        </div>
        <p v-if="item.price" :class="$style.btn">
          <x-button mini v-if="item.price && !item.isMyFilm">购买</x-button>
          <x-button mini v-else-if="item.price && item.isMyFilm">已购买</x-button>
        </p>
      </div>
    </div>
  </dd>
</dl>
</template>

<script>
import { XButton } from 'vux'
export default {
  props: {
    lists: {
      type: Array,
      default: () => []
    },
    title: {
      type: String,
      default: ''
    }
  },
  components: {
    XButton
  },
  methods: {
    handleItemClick (item) {
      this.$emit('handleItem', item)
    }
  }
}
</script>

<style lang='less' module>
.container {
  padding: 20px 20px 0px;
  box-sizing: border-box;
  dt {
    line-height: 0;
    margin-bottom: 10px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    .icon { 
      display: inline-block;
      width: 18px;
      height:18px;
      background: url('../../../assets/imgs/index_icon.png') no-repeat;
      background-position-x: center;
      background-size:18px;
      vertical-align: middle;
    }
    span {
      margin-left:10px;
      font-size:14px;
      font-weight: bold;
      color:#2b333b;
      vertical-align: middle;
    }
    em {
      font-size:14px;
      color:#2b333b;
      vertical-align: middle;
    }
  }
  dd {
    margin: 10px 0px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    .left {
      img {
        width: 108px;
        height:70px;
        object-fit: cover;
        border-radius: 5px;
      }
    }
    .right {
      width: calc(~"100% - 120px");
      padding-left: 12px;
      .title {
        color: #2B333B;
        font-size: 15px;
        font-weight: bold;
        line-height: 20px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-all;
        word-wrap: break-word;  
      }
      .count {
        margin-top: 8px;
        font-size: 12px;
        color: #71777D;
        line-height: 14px; 
      }
      .desc {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        line-height: 0px;
        align-items: center;
        .price {
          span {
            font-size: 12px;
            line-height: 14px;  
          }
          .f1 {
            color: red;
          }
          .f2 {
            color: #be9e4d;
          }
        }
        .btn {
          button {
            background: red;
            color:#fff;
          }
        }
      }
    }
  }

}

</style>
